import request from '../utils/request'

// 获取公钥
export const getPublicKey = () =>
  request({
    url: '/public/generate/rsa',
    notEncrypt: true,
    method: 'GET',
  })

// 上传tgt 用户信息到tfsmy server
export const uploadUserInfo = (data: {
  aid: string
  tgt: string
  userDTO: AnyObject | ''
  code?: string
  openId:string
}) =>
  request({
    url: '/oauth2/miniProgramAuth',
    notEncrypt: true,
    method: 'POST',
    header: { 'content-type': 'application/json' },
    data,
  })

export const validateAuthApi = () =>
  request({
    url: '/auth/login/checkTgt',
    method: 'GET',
    notEncrypt: true,
  })

// 获取webview加密key
export const getWebviewAuth = () =>
  request({
    url: '/auth/rsa/keygen',
    method: 'GET',
  })

// 退出登录，清除授权信息
export const sysLogout = () =>
  request({
    url: '/auth/login/logOut',
    method: 'POST',
  })

// h5登录
export const oauth2 = (data = {}) =>
  request({
    url: `/oauth2/auth`,
    notEncrypt: true,
    method: 'GET',
    data,
  })

/*获取用户信息*/
export const getUserInfo = (data = {}) =>
  request({
    url:'/oauth2/callback',
    notEncrypt: true,
    method: 'GET',
    data,
  })

// 小程序获取openId
export const openIdCode = (data = {}) => {
  return request({
    url: `/oauth2/getOpenId`,
    notEncrypt: true,
    method: 'GET',
    data,
    noLoading:true
  })
}

/*转移用户提示*/
export const transferTips = (data = {}) =>
  request({
    url:'/mobile/institutional/transferTips',
    method:'GET',
    data
  })
/*转移转移用户*/
export const transfer = (data = {}) =>
  request({
    url:'/mobile/institutional/transfer',
    method:'GET',
    data
  })

/*获取机构详情*/
export const mechanismInfo = (data = {}) =>
request({
  url:'/mobile/institutional/show',
  method:'GET',
  data
})

/*查看机构报名训练营*/
export const mechanismList = (data={}) =>
  request({
    url:'/mobile/registration/institutional/list',
    method:'GET',
    data,
    noLoading:true
  })

/*机构根据训练营 id 获取报名人员信息列表*/
export const institutionalUserList = (data={}) =>
  request({
    url:'/mobile/registration/institutional/user/list',
    method:'GET',
    data
  })

/*用户关联机构*/
export const userBindInstitutional= (data={}) =>
  request({
    url:'/mobile/institutional/userBindInstitutional',
    method:'GET',
    data
  })

/*同步数据*/
export const syncData = (data={}) =>
  request({
    url:'/mobile/syncData',
    method:'GET'
  })


/*获取客服列表*/
export const userContactList = (data ={}) =>
  request({
    url:'/mobile/contact/public/list',
    method:'GET'
  })
